# -*- coding: utf-8 -*-

import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QToolTip, QWidget, QMessageBox
from PyQt5 import QtCore, QtWidgets, QtGui
from PyQt5.QtGui import QFont
from utils import FileUtil

from views import Ui_mainWindow

class Run():
    def __init__(self):
        pass

    def click_btn(self):
        host = self.ui.lineEdit.text()
        name = self.ui.lineEdit_3.text()
        port = self.ui.lineEdit_4.text()
        user = self.ui.lineEdit_5.text()
        pawd = self.ui.lineEdit_6.text()
        print(host, 'host')
        print(name, 'name')
        print(port, 'port')
        print(user, 'user')
        print(pawd, 'pawd')
        # self.tool_tip()
        self.default_db_conn()
        print(self.db_config)


    # def tool_tip(self):
    # self.mainWindow.setStatusBar().showMessage('链接成功')
    def default_db_conn(self):
        file = FileUtil.ConfigUtil()
        self.db_config = file.get_json()


    def main(self):
        # 创建应用程序和对象
        app = QApplication(sys.argv)
        self.mainWindow = QMainWindow()
        self.ui = Ui_mainWindow.Ui_MainWindow()
        self.ui.setupUi(self.mainWindow)
        self.mainWindow.statusBar().showMessage('ready')
        self.mainWindow.setWindowTitle('链接数据库')  # 窗体标题
        self.mainWindow.show()

        self.ui.lineEdit_6.setText('asdfasdf')
        self.ui.textBrowser.setText('这个是测试链接数据库')

        self.ui.pushButton.clicked.connect(self.click_btn)

        sys.exit(app.exec_())



if __name__ == '__main__':

    run = Run()
    run.main()



